home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
-
- LPDIRECTINPUT DI = 0;
-
- void init_directinput()
- {
- if (FAILED(DirectInputCreate(theApp.m_hInstance, DIRECTINPUT_VERSION, &DI, 0)))
- error("Unable to create DirectInput interface\n\n"
- "Did you install DirectX 6.0 or higher?");
- }
-
- void deinit_directinput()
- {
- safe_release(&DI);
- }
-
- LPDIRECTINPUTDEVICE2 create_input_device(GUID guid)
- {
- LPDIRECTINPUTDEVICE id1;
- LPDIRECTINPUTDEVICE2 id2;
-
- if (FAILED(DI->CreateDevice(guid, &id1, 0)))
- error("Unable to get DirectInputDevice interface");
-
- if (FAILED(id1->QueryInterface(IID_IDirectInputDevice2, (LPVOID *)&id2)))
- error("Unable to get DirectInputDevice2 interface");
-
- id1->Release();
-
- return id2;
- }
-